package leecode.数组和字符串.反转字符串;

public class reverseString {
    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        char[] array = {'h', 'e', 'l', 'l', 'o'};
        System.out.println(array);
        Solution solution = new Solution();
        solution.reverseString(array);
        System.out.println(array);
        long endTime = System.currentTimeMillis(); //获取结束时间
        System.out.println("程序运行时间： " + (endTime - startTime) + "ms");

    }

    static class Solution {
        public void reverseString(char[] s) {
            char temp;
            if (s.length == 0) {
                return;
            }
            for (int left = 0, right = s.length - 1; left < right; ++left, --right) {
                temp = s[left];
                s[left] = s[right];
                s[right] = temp;

            }
        }
    }
}
